<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
    </div>
    <script>
        const div=document.querySelector('div')
        function fn(){
             const now=new Date()
             const year=now.getFullYear()
             const month=now.getMonth()
             const date=now.getDate()
             let h=now.getHours()
             let m=now.getMinutes()
             let s=now.getSeconds()
             h=h<10 ? '0'+h : h
             m=m<10 ? '0'+m : m
             s=s<10 ? '0'+s :s
             return `今天是:${year} - ${month}-${date}  ${h}:${m}:${s}`
        }
        setInterval(function(){
            div.innerHTML=fn()
        },1000)
        
</script>
</body>
</html>